﻿
@{ Layout = null;}
@using Shop.Entity;
@model TBrand
<div class="modal fade" id="Add" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="headerTitle">新增品牌</h4>
            </div>
            <div class="modal-body">
                <div class="portlet-body form">
                    @using (Html.BeginForm("AddPost", "Brand", FormMethod.Post, new { id = "add", @class = "form-horizontal" }))
                    {

                        @Html.HiddenFor(c => c.Guid)
                        @Html.HiddenFor(c => c.OperatorGuid)
                        <div class="form-body">
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        品牌<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control input-sm" name="Title" id="Title" datatype="s2-80" nullmsg="请输入品牌名称!" sucmsg=" " errormsg="名称至少2个字符,最多80个字符！" value="@Model.Title" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">Logo<span class="required"> &nbsp; </span></label>
                                    <div class="col-sm-5">
                                        <div class="input-group" style="cursor:pointer ;" id="image1">
                                            @Html.TextBoxFor(c => c.Logo, new { @id = "url1", @class = "form-control input-sm", @value = "", @readonly = "readonly" })
                                            <span class="input-group-btn">
                                                <button class="btn btn-primary btn-sm" type="button" id="">上传图片</button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            @*<div class="row">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">
                                            所属分类<span class="required"> * </span>
                                        </label>
                                        <div class="col-sm-5">
                                            @Html.DropDownListFor(c => c.GoodsCategoryGuid, (SelectList)ViewData["CateGory"],  new { id = "Category", @class = "form-control input-sm" })
                                        </div>
                                    </div>
                                </div>*@
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        网址<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control input-sm" name="Url" id="Url" datatype="*" nullmsg="请输入跳转连接!" sucmsg=" " errormsg="请输入跳转连接!" value="@Model.Url" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        排序<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control input-sm input-inline" name="Sort" id="Sort" datatype="n" nullmsg="请输入数字!" sucmsg=" " errormsg="请输入数字!" value="@Model.Sort" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        备注<span class="required"> &nbsp; </span>
                                    </label>
                                    <div class="col-sm-6">
                                        <textarea class="form-control input-sm" rows="3" cols="20" id="Remark" name="Remark" ignore="ignore" datatype="*1-300" errormsg="备注不能超过300个字符!" sucmsg=" ">@Model.Remark</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label for="message-text" class="col-sm-3 control-label"></label>
                                    <div class="col-sm-6" id="tip">
                                        &nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="submit" class="btn btn-primary" value="保存" />
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('#Add').on('hidden.bs.modal', function (e)
    {
        parent.layer.closeAll('tips'); //关闭所有的tips层
    })
    function ShowValidformMsg(msg, id)
    {
        layer.tips(msg, '#' + id, { tipsMore: true });
    }
    $(function ()
    {
        $("#add").Validform({
            showAllError: true,
            ajaxPost: true,
            beforeSubmit: function (curform)
            {
                parent.layer.msg('正在执行操作...', { icon: 16 });
                return true;
            },
            callback: function (data)
            {
                if (data.success)
                {
                    parent.layer.closeAll();
                    parent.layer.msg(data.msg, { icon: 1 });
                    $('#Add').modal('hide')
                    if ($("#pageItem").find(".active").find("a").html() != undefined) {
                        $("#pageItem").find(".active").find("a").click();
                    } else {
                        $("#formSearch").submit();
                    }
                } else
                {
                    parent.layer.msg(data.msg);
                }
            },
            tiptype: function (msg, o)
            {
                if (msg.trim() != "" && o.type != 1)
                { ShowValidformMsg(msg, $(o.obj).attr("id")); }
            }
        }
     );
    })

</script>
